﻿using System;
using System.Windows.Input;
using JulMar.Windows.Mvvm;
using JulMar.Windows.Validations;
using MediaBrowser.Gui.MvvmUtils.UI;

namespace MediaBrowser.Gui.ViewModels
{
    /// <summary>
    /// View Model base
    /// </summary>
    public class ViewModelBase : ValidatingViewModel
    {
        protected ICustomMessageBoxVisualizer icustomMessageBoxVisualizer;

        public ICommand CloseCommand
        {
            get;
            private set;
        }

        public ViewModelBase()
        {
            CloseCommand = new DelegatingCommand(OnRequestClose);
            icustomMessageBoxVisualizer = Resolve<ICustomMessageBoxVisualizer>();
        }

        #region RequestClose [event]

        public event EventHandler RequestClose;

        void OnRequestClose()
        {
            EventHandler handler = this.RequestClose;
            if (handler != null)
                handler(this, EventArgs.Empty);
        }

        #endregion RequestClose [event]
    }
}
